const url = 'https://web.sunsk.top'

const Request = (options) => {
	return new Promise((resolve, reject) => {
		options.data.appid = "21210416"
		options.data.ranstr = "1n7sdkk7fu37qvvj"
		options.data.secret = "ykzc"
		options.data.sign = "98fc4c4c3fbc9302a41766c1b18157d8"
		options.data.times = "1715666153667"
		options.data.token = uni.getStorageSync("token") || '' 
		uni.request({
			url: url + options.url,
			method: options.method || 'GET',
			data: options.data || {},
			header: {},
			success: (res) => {
				console.log(res)
				if(res.data.msg == '凭据已过期，请重新登录'){
					uni.removeStorageSync('token')
					uni.navigateTo({
						url:'/pages/login/index'
					})
				}
				if(res.data.msg == '请重新登录'){
					uni.removeStorageSync('token')
					uni.navigateTo({
						url:'/pages/login/index'
					})
				}
				uni.hideLoading()
				resolve(res.data);
			},
			fail: (err) => {
				uni.hideLoading()
				reject(err.data);
			},
		});
	})
}
export default Request